#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int qrdetection(){
	QRCodeDetector qrDecoder = QRCodeDetector();
	Mat rectifiedImage;
	vector<Point> bbox;
	string inputName="qr.jpg";
	Mat image = imread(inputName);
    std::string data = qrDecoder.detectAndDecode(image, bbox, rectifiedImage);
	imshow( "result0", image );
	if(data.length()>0){
		cout<<data<<endl;
		int n = bbox.size();
		for(int i = 0 ; i < n ; i++){			
			if((i+1)==n){
				//最后一个点要跟第一个点相连
				line(image, bbox[i],bbox[0], Scalar(255,0,0), 3);
			}else{
				line(image, bbox[i],bbox[i+1], Scalar(255,0,0), 3);
			}
		}
		imshow("Result", image);
		waitKey(0);
	}else{
		//cout<<"not cinf"<<endl;
	}
	return 0;
}